package com.serviceImpl;

import com.mapper.AccountMapper;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("userService")
public class UserServiceImpl implements UserService {
    @Autowired
    AccountMapper accountMapper;


    //在出现事务操作的方法上使用注解标识 自动进行事务处理
    @Transactional
    @Override
    public void transferAccounts(int outId, int inId, double money) {
        accountMapper.updateSubMoneyById(outId, money);
        //System.out.println(1/0);
        accountMapper.updateAddMoneyById(inId, money);
    }
}